package com.iaz.tech.tools.common.flow.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iaz.tech.tools.common.flow.IFlowAble;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * if 语句
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class IFFlow extends FlowsGroup {
	/**
     * 日志
     */
	private final static Logger logger = (Logger) LoggerFactory.getLogger(IFFlow.class);

    private IFlowAble boundary = null;

	/**
     * 执行流程
     */
    @Override
    public Object executeFlow(Object property) {
        Object result = null;
        try {
            if (this.boundary == null) {
                logger.warn("IFFlow boundary is null");
                return result;
            }
            // 执行条件判断
            if ((Boolean) this.boundary.executeFlow(property)) {
                // 执行then分支
                result = super.executeFlow(property);
            }
        } catch (Exception e) {
            logger.error("IFFlow executeFlow error", e);
        }
        return result;
    }
    /**
     * 执行前处理
     */  
    @Override
    public Object beforeExecute(Object property) {
        Object result = null;
        return result;
    }
    /**
     * 执行后处理
     */
    @Override
    public Object afterExecute(Object property) {
        Object result = null;
        return result;
    }
}
